
<?php 
	echo $this->doctype();
    echo $this->headScript();
?>

<html xmlns="http://www.w3.org/1999/xhtml"> 
	<head>  
	  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
	  <title>Spagooy beta - Spagooy: Play a game of online Yatzy</title>
	  <?php echo $this->headLink()->appendStylesheet('/css/master.css') ?>
	</head> 
	<body>
		<div id="container">
			<?php
				$url = $_SERVER['REQUEST_URI'];
				$params = explode('/', $url);
				$languagesString = Zend_Registry::get('config')->languages;
				$languages = explode('/', $languagesString);
				$retUrl = "/";
				$lang = "";
				if (in_array($params[1], $languages)){
					$lang = "/" . $params[1];	
					for ($i = 2; $i < count($params); ++$i){
						if ($params[$i] != ""){
							$retUrl = $retUrl . $params[$i] . "/";
						}
					}
				} else {
					for ($i = 1; $i < count($params); ++$i){
						if ($params[$i] != ""){
							$retUrl = $retUrl . $params[$i] . "/";
						}
					}
				}
				?>
			<div id="head">
				<div class="wrap">
					<div id="lanLogDiv">
						<div id="languageChoice">
							<ul>
								<?php
									$langs = Zend_Registry::get('config')->lang->toArray();
									
									//for($i=0; $i<count($langs); ++$i)
									{
										while($language = current($langs))
										{
											$langCode = key($langs);
											?>				
											<li>
												<?php 
													if (in_array($params[1], $languages))
													{
														if ($params[1] == $langCode){
															?><a href=""><img src="http://spagooy.com/pics/flags/<?php echo($langCode); ?>.png" alt="<?php echo($language); ?>" title="<?php echo($language); ?>"/></a><?php
														} else {
															?><a href="http://<?php echo $_SERVER['SERVER_NAME'] . "/" . $langCode .  $retUrl ?>">	<img src="http://spagooy.com/pics/flags/<?php echo($langCode); ?>.png" alt="<?php echo($language); ?>" title="<?php echo($language); ?>"/></a><?php														
														}
													} else
													{			
														?><a href="http://<?php echo $_SERVER['SERVER_NAME'] . "/" . $langCode .  $retUrl ?>"><img src="http://spagooy.com/pics/flags/<?php echo($langCode); ?>.png" alt="<?php echo ($language) ?>" /></a><?php					
													}
												?>
											</li>
											<?php
											
											next($langs);
										}
									}			
								?>
								
							</ul>
						</div>
						
						<div id="loginDiv">
							<ul>
								<?php
									$auth = Zend_Auth::getInstance();
									if ($auth->hasIdentity() == false){ ?>
										<li>
									    	<?php
											$l = "<a href='http://" . $_SERVER["SERVER_NAME"] . $lang . "/register'>" . Zend_Registry::get('translate')->_("SIGN_UP") . "</a>";
											echo($l);
											?>						
									    </li>
									<?php } ?>
							    <li>
							    	
							    	<?php
									$auth = Zend_Auth::getInstance();
									$l;
									if ($auth->hasIdentity()){
										$l = "<a href='http://" . $_SERVER["SERVER_NAME"] . $lang . "/logout'>" . Zend_Registry::get('translate')->_("LOGOUT") . "</a>";
									}else{
										$l = "<a href='http://" . $_SERVER["SERVER_NAME"] . $lang . "/login'>" . Zend_Registry::get('translate')->_("LOGIN") . "</a>";
									}
			
									echo($l);
									?>						
							    </li>
								
								<li>
									<?php
									$l = "<a href='http://" . $_SERVER["SERVER_NAME"] . $lang . "/contact'>" . Zend_Registry::get('translate')->_("CONTACT_US") . "</a>";
									echo($l);
									?>
								</li>
							</ul>	
							<div class="empty"></div>							
						</div>
					</div>
					
					<div id="logo">
						<!--<a href="<?php echo('http://'.$_SERVER["SERVER_NAME"] . $lang); ?>"><h1>Spagooy <span class="super">beta</span></h1></a> -->
						<a href="<?php echo('http://'.$_SERVER["SERVER_NAME"] . $lang); ?>"><img src="/pics/logo/spagooy_beta_green_trimmed.png" alt="Spagooy beta" /></a>
					</div>
				</div>
				
				<div class="empty"></div>
			</div>
			
			<div id="mainMenu">
					<div class="wrap">
						<ul>
							<?php  
								if ($url == $lang || $url == $lang . "/"){
									?> <li class="active"> <?php
								} else {
									?> <li> <?php
								}
							?>
							<?php
								$l = "<a href='http://" . $_SERVER["SERVER_NAME"] . $lang . "/'>" . Zend_Registry::get('translate')->_("HOME") . "</a>";
								echo($l);						
							?>
						    </li>
							<?php  
								if ($url == $lang . "/game" || $url == $lang . "/game/"){
									?> <li class="active"> <?php
								} else {
									?> <li> <?php
								}
							?>
						    	<?php
								$l = "<a href='http://" . $_SERVER["SERVER_NAME"] . $lang . "/game'>" . Zend_Registry::get('translate')->_("PLAY") . "</a>";
								echo($l);
								?>						
						    </li>
							<?php  
								if ($url == $lang . "/statistics/highscore" || $url == $lang . "/game/"){
									?> <li class="active"> <?php
								} else {
									?> <li> <?php
								}
							?>
						    	<?php
								$l = "<a href='http://" . $_SERVER["SERVER_NAME"] . $lang . "/statistics/highscore'>" . Zend_Registry::get('translate')->_("HIGHSCORE") . "</a>";
								echo($l);
								?>						
						    </li>
		
							<?php if(false): if ($auth->hasIdentity()){ ?>
							    <li>
						    		<?php
									$l = "<a href='http://" . $_SERVER["SERVER_NAME"] . $lang . "/mypage'>" . Zend_Registry::get('translate')->_("MY_PAGE") . "</a>";
									echo($l);
									?>						
						    	</li>
							<?php } endif;?>
						</ul>
					</div>
				</div>
			
			<div id="content" class="wrap">
				<?php echo $this->layout()->content ?>
				<div class="empty"></div>
			</div>
			
			<div id="footer">
				<div class="wrap">
					<p>© Spagooy 2009</p>
					<div class="empty"></div>
				</div>
			</div>
		</div>
	</body>
</html>
